package com.kisszpy.system.dao;

import java.util.List;



import com.kisszpy.core.dao.HibernateGenericDao;
import com.kisszpy.system.entity.SysMenu;

public class SysMenuDao extends HibernateGenericDao<SysMenu>{
	@SuppressWarnings("unchecked")
	public List<SysMenu> getMenus(Integer[] ids){
		String in = "";
		for(int i = 0;i<ids.length;i++){
			in+=ids[i]+",";
		}
		in = in.substring(0, in.length()-1);
		/*
		 * String sql = "select distinct m.* from t_sys_menu m left join t_sys_action a on m.a_id = a.id left join t_sys_role_menu rm on rm.r_id in(1,2)";
		SQLQuery squery = this.getSession().createSQLQuery(sql);
		List list = squery.list();
		JSONArray json = JSONArray.fromObject(list);
		System.out.println(json.toString());*/
		/*public SysMenu(Integer id, String name, Integer pid, SysAction action,
			Integer sortNum) {
		 * */
		String hql = "select distinct new SysMenu(m.id,m.name,m.pid,m.action,m.sortNum) from SysRole r inner join r.menuSet m where r.id in("+in+")";
		List<SysMenu> list = this.getSession().createQuery(hql).list();
		return list;
		
	}
}
